import Vue from 'vue'
import Vuex from 'vuex'
import areaList from '../utils/area'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 用户信息
    userInfo: {},
    isLogin: false
  },
  mutations: {
    CHANGEUSERINFO (state, newUserInfo) {
      state.userInfo = newUserInfo
    },
    CHANGEISLOGIN (state, isLogin) {
      state.isLogin = isLogin
    },
    CHANGEPROP (state, map) {
      state.userInfo[map.propName] = map.propValue
    }
  },
  getters: {
    avatarUrl (state) {
      return process.env.VUE_APP_URL + state.userInfo.avatar
    },
    genderText (state) {
      const map = {
        0: '未知',
        1: '帅哥',
        2: '女的'
      }
      return map[state.userInfo.gender]
    },
    areaText (state) {
      return areaList.city_list[state.userInfo.area]
    }
  },
  actions: {},
  modules: {}
})
